import json
import requests
from lxml import etree
import urllib3
urllib3.disable_warnings()
base_url = "https://www.hbjcxy.com/jyyw/"
# 请求
response = requests.get(base_url,verify=False)
# 设置编码方式
response.encoding = "utf-8"
# 解析网页
node = etree.HTML(response.text)
# 新闻标题
titles = node.xpath("//div[@class='list-item']//a/text()")
dates = node.xpath("//div[@class='list-meta']/text()")
# 定义一个列表保存信息
items = []
for t in range(len(titles)):
    d = {}
    d["标题"] = str(titles[t]).strip()
    d["时间"] = str(dates[t]).strip()
    items.append(d)
print(items)
with open("标题和时间.json","w+",encoding="utf-8") as f:
    f.write(json.dumps(items,ensure_ascii=False,indent=2))